#!/bin/bash

# <bitbar.title>Vertcoin BTC price at Bittrex</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Cem Yildirim</bitbar.author>
# <bitbar.author.github>cemyld</bitbar.author.github>
# <bitbar.desc>Shows the last Vertcoin price (in BTC) on the Bittrex exchange.</bitbar.desc>
# <bitbar.image>https://imgur.com/DEOGHG6.jpg</bitbar.image>
# <bitbar.abouturl>https://www.vertcoin.org/bitbar.abouturl>
#


vtcIconBase64="iVBORw0KGgoAAAANSUhEUgAAAFgAAABYCAYAAABxlTA0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAADXUAAA11AFeZeUIAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAAMxElEQVR42u1de4xcVRm/M7OKr4rB1tbdnXvOuffO7Mb1D00V0GizKiAK2oTER3xElEaJVpSAplpfqQgmRhEUSSMGaKwPAuofpAEaEq3WkJqolCIoq7GW1qKIaEXd2ZlZv+/cc8795rUz99y59+7eOMnJtDOz9/Gd7/y+3/c613GyfZVgVOYdZ6L7C87587xq9WWB677LZ2wXjD0w9vsu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pGKNk7c+nvi6jmAqagRlp1HXgWuZiZarE6719kAfMATNOfMcYELs+MDXMn72XsoricvayE/LWc+pb19ob7B+BxvwD6Yh7XiCk3G3e+rAzHadihk4uQI2y7mmhHSYcflXB3kChg9jsDMnbMehsaE5OVHaDmBpoZ47F0QoQr3qSppG7HkkXfyVsfknQvyRLeBNvQkNotJraRLGwrazyWRd4qSC+vB7AZPnuolv2mpNIpCplOuAGHk3BvNVpH8JVaPlsqNg0nd/mPYNyiq5G87I3aouLqN1uGUYcUybn8e+GmoJkLudXnkRBZN00uyq1jOh2hsW3/VelpWsxDyNEzM/LRXMYPmu3HU9h2cUIfGIVMNLmoW34Z4YabHvGDM+vXr7PMDcYrK1VpnduI4WsWULgtE+UDWNCam8V2t1TI13VtjF+YPmfS8HNzd6wmixfdavwDONu1YmzaLCEhChEYKpbZHu7d7EK71K/EzSpMDe9a7NoPr7mlUmbHtBPhkMdZ5PEq6WUTbgnGd8snq3Djvq4FbG5q11dx673E/V0dz5+jwI9hRuxZo4/aWaWC7n7UzoKOimVlzKwhI9wDSFyJIcdOx0Dk/7AoeQ2hC64E+yQGy0k8N1dIiKXNmF8LHx/JT9aiZ8i1iVZn/bizlhYsxjcwh0bSPB0Ru9X+KlOrixU6uLmF7ouudzwBETXKPFyvPT6BhpqqI3JkJT2MqXWS/dVYuyafjFjp6suYQOuM+4rp8oDeR04K8gjJoQ9CodrZ0I+f0IaWHPc45uyw4obsPqWpV8UpwKvSTdLVXkFvwN2ZcAMhuceNEnh9yANTffLg1FrX35jNPzk/JB9dVuVbaSFe0QQ7CDp6bi6YCqZxFxTcKgF3CsHGc9xvAbTyrwO0uB3iKL8fYyNy5xXOL8eyfVNZ3jPJ2UPB/wDyIQMG6nx4bwAAAABJRU5ErkJggg=="
vtcLast=$(curl -s https://bittrex.com/api/v1.1/public/getticker?market=btc-vtc | tr -d '{}"' | tr ':,' '\n' | grep -A1 "Last" | tail -1)
printf "%.*f | templateImage=%s\n" 5 "$vtcLast" "$vtcIconBase64"
echo "---"
echo "Live Graph | href=\"https://bittrex.com/Market/Index?MarketName=BTC-VTC\""
